package actions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import src.Editor;
import src.MidiPlayer;

public class ActionLoad implements ActionListener{

	MidiPlayer mp;
	Editor ed;
	public ActionLoad(MidiPlayer mp,Editor ed) {
		this.mp = mp;
		this.ed = ed;
	}

	public void actionPerformed(ActionEvent arg0) {

		JFileChooser fileChooser = new JFileChooser();
		FileNameExtensionFilter filter = new FileNameExtensionFilter("Midi Files", "midi","mid");  
		fileChooser.addChoosableFileFilter(filter);  
		int option =  fileChooser.showOpenDialog(null);
		if(option != JFileChooser.CANCEL_OPTION && option != JFileChooser.ABORT){
			this.mp.playMidi(fileChooser.getSelectedFile().getAbsolutePath());
			ed.viewPanels();
		}
		
	}

}
